/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package au.edu.swin.bank.persistence.entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author scott
 */
@Entity
@Table(name = "BILLER")
@NamedQueries({
    @NamedQuery(name = "Biller.findAll", query = "SELECT b FROM Biller b"),
    @NamedQuery(name = "Biller.findByBillerid", query = "SELECT b FROM Biller b WHERE b.billerid = :billerid"),
    @NamedQuery(name = "Biller.findByName", query = "SELECT b FROM Biller b WHERE b.name = :name")})
public class Biller implements Serializable {
    private static final long serialVersionUID = 1L;
    @JoinColumn(name = "ACCOUNTID", referencedColumnName = "ACCOUNTID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Account account;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "biller")
    private Collection<Bill> billCollection;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "BILLERID")
    private Integer billerid;
    @Column(name = "NAME")
    private String name;

    public Biller() {
    }

    public Biller(Integer billerid) {
        this.billerid = billerid;
    }

    public Integer getBillerId() {
        return billerid;
    }

    public void setBillerId(Integer billerid) {
        this.billerid = billerid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }
    
    public Collection<Bill> getBillCollection() {
        return billCollection;
    }

    public void setBillCollection(Collection<Bill> billCollection) {
        this.billCollection = billCollection;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Biller)) {
            return false;
        }
        Biller other = (Biller) object;
        if ((this.billerid == null && other.billerid != null) || (this.billerid != null && !this.billerid.equals(other.billerid))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (billerid != null ? billerid.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "au.edu.swin.bank.persistence.entity.Biller[billerid=" + billerid + "]";
    }
}
